/**
 * 上海中赢金融信息服务有限公司
 * Copyright (c) 2015-2025, izene soft All Rights Reserved.
 */
package com.sys.midware.config.factory;

import java.io.InputStream;
import java.util.Map.Entry;

import com.sys.midware.config.core.Configuration;

import java.util.Properties;
import java.util.Set;

/**
 * 
 * <b>ClassName：</b> PropertiesConfigurationFactory <br/>
 * <b>Description：</b> 对properties文件进行配置解析的工厂 <br/>
 * <b>@author：</b> mobing <br/>
 * <b>@date：</b> 2015年10月16日 下午3:25:55 <br/>
 * <b>@version: </b>  <br/>
 */
public class PropertiesConfigurationFactory implements
		AbstractConfigurationFactory {

//	@Override
//	public Configuration parseConfigFile(File filePath) throws Exception{
//		Properties prpt = new Properties();
//		prpt.load(new FileReader(filePath));
//		
//		Configuration conf = new Configuration();
//		Set<Entry<Object, Object>> set = prpt.entrySet();
//		for(Entry<Object, Object> entry : set){
//			conf.addParam(entry.getKey().toString(), entry.getValue());			
//		}
//		
//		return conf;
//	}

//	@Override
//	public Configuration parseConfigFile(InputStream input) throws Exception {
//		Properties prpt = new Properties();
//		prpt.load(input);
//		
//		Configuration conf = new Configuration();
//		Set<Entry<Object, Object>> set = prpt.entrySet();
//		for(Entry<Object, Object> entry : set){
//			conf.addParam(entry.getKey().toString(), entry.getValue());			
//		}
//		
//		return conf;
//	}
	
	
	   @Override
	    public void parseConfigFile(InputStream input,Configuration cfg) throws Exception {
	        Properties prpt = new Properties();
	        prpt.load(input);
	        Set<Entry<Object, Object>> set = prpt.entrySet();
	        for(Entry<Object, Object> entry : set){
	            cfg.addParam(entry.getKey().toString(), entry.getValue());         
	        }
	    }

}
